export default {
	namespaced: true,
	
	state: () => ({
		userinfo: JSON.parse(uni.getStorageSync('userinfo') || '{}'),
		token: uni.getStorageSync('token') || ''
	}),
	
	mutations: {
		updateUserInfo(state, userinfo) {
			state.userinfo = userinfo
			this.commit('m_user/saveUserinfoToStorage')
		},
		saveUserinfoToStorage(state) {
			uni.setStorageSync('userinfo', JSON.stringify(state.userinfo))
		},
		
		updateToken(state, token) {
			state.token = token,
			this.commit('m_user/saveToken')
		},
		saveToken(state) {
			uni.setStorageSync('token', state.token)
		}
	},
	
	getters: {}
}